<?php
   //登录 后端 前端传来name pwd 查找数据库中是否有

   //获取前端传过来的参数
   $name = $_POST['name'];
   $pwd = $_POST['pwd'];

   $conn = mysqli_connect('localhost', 'root', 'root', '2008');
   mysqli_query($conn, "set charset 'utf8'");
   mysqli_query($conn, "set character set 'utf8'");

   $sql = "select * from users where name='$name' and pwd=$pwd";
   $res = mysqli_query($conn,$sql);
   $count = mysqli_num_rows($res);
   if($count>0){
      echo json_encode(array(
         'code'=>200,
         'body' => array(
            'msg'=>'登陆成功，跳往首页'
         )
         ));
   }else{
      echo json_encode(array(
         'code'=>201,
         'body' => array(
            'msg'=>'登录失败，网络出错请重试'
         )
         ));
   }